package org.eoti.game.roshambo;

/**
 * The MIT License
 * <p/>
 * Copyright (c) 2009 Malachi de AElfweald (malachid@gmail.com)
 * <p/>
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * <p/>
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
 * Software.
 * <p/>
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
public class Judgement<WEAPON extends Weapon<WEAPON>, PLAYERID, PLAYER extends Player<PLAYERID, WEAPON>>
{
	public enum Winner{Player1,Player2,Tie}

	private Challenge<WEAPON, PLAYERID, PLAYER> challenge;
	private Winner winner;
	private String description;

	public Judgement(Challenge<WEAPON, PLAYERID, PLAYER> challenge, Winner winner, String description)
	{
		this.challenge = challenge;
		this.winner = winner;
		this.description = description;
	}

	public Challenge<WEAPON,PLAYERID,PLAYER> getChallenge(){return challenge;}
	public Winner getWinner(){return winner;}
	public String getDescription(){return description;}

	public String toString()
	{
		switch(winner)
		{
			case Player1:
				return String.format("%s: %s beats %s", description, challenge.getPlayer1().getId(), challenge.getPlayer2().getId());
			case Player2:
				return String.format("%s: %s beats %s", description, challenge.getPlayer2().getId(), challenge.getPlayer1().getId());
			default:
				return String.format("%s: %s ties %s", description, challenge.getPlayer1().getId(), challenge.getPlayer2().getId());
		}
	}
}
